/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function (head) {
    // dummy 口头指针
    let dummy = new ListNode()
    dummy.next = head
    // 创建三剑客
    let cur = head
    let pre = null
    let next = null
    // 实现翻转
    while (cur) {
        next = cur.next
        cur.next = pre
        pre = cur
        cur = next
    }
    // 空头指针指向最后一位
    dummy.next = pre
    return dummy.next
};